import React from 'react';
import { Consumer } from "./Context";//引入父组件的Consumer容器
import Grandson from "./Grandson.js";//引入子组件
function Son(props) {
    return (
        //Consumer容器,可以拿到上文传递下来的name属性,并可以展示对应的值
        <Consumer>
            {( data ) =>
                <div className="son">
                    <p>子组件:获取父组件的值:{data.son}</p>
                    {/* 孙组件内容 */}
                    <Grandson />
               </div>
            }
        </Consumer>
    );
}
export default Son;